package com.xz.knowledgeDuplication.pattern.facade;

/**
 * 智能音响(外观角色) 个人感觉很鸡肋
 *
 * @author 召
 * @date 2022-03-13 17:41:43
 */
public class SmartSpeaker {

    private Light light;

    private TV tv;

    public SmartSpeaker() {
        light = new Light();
        tv = new TV();
    }

    public void say(String message) {
        if(message.contains("打开")) {
            on();
        } else if (message.contains("关闭")) {
            off();
        } else {
            System.out.println("很抱歉暂不支持该功能");
        }
    }

    private void on() {
        light.on();
        tv.on();
    }

    private void off() {
        light.off();
        tv.off();
    }
}
